package com.lhnstart.learn.bases.enum_;

import sun.management.Sensor;

/**
 * 枚举类简介
 *
 * @author lhn
 * @date 2023/07/19 10:01
 * @since 1.0.0
 **/
public class Enumeration01 {

    public static void main(String[] args) {
        /*Season spring = new Season("spring", "warm");
        Season winter = new Season("winter", "cold");
        Season summer = new Season("summer", "hot");
        Season fall = new Season("fall", "cold");*/
        System.out.println(Season.SPRING);
        System.out.println(SeasonEnum.SPRING);


    }

}

class Season {

    private String name;
    private String desc;

    // 定义了四个对象
    public final static Season SPRING = new Season("spring", "warm");
    public final static Season WINTER = new Season("winter", "cold");
    public final static Season SUMMER = new Season("summer", "hot");
    public final static Season FALL = new Season("fall", "cold");

    private Season(String name, String desc) {
        this.name = name;
        this.desc = desc;
    }

    public String getName() {
        return name;
    }

    public String getDesc() {
        return desc;
    }

    @Override
    public String toString() {
        final StringBuffer sb = new StringBuffer("Season{");
        sb.append("name='").append(name).append('\'');
        sb.append(", desc='").append(desc).append('\'');
        sb.append('}');
        return sb.toString();
    }
}

enum SeasonEnum {

    SPRING("spring", "warm"),
    WINTER("winter", "cold"),
    SUMMER("summer", "hot"),
    FALL("fall", "cold");

    private String name;
    private String desc;


    private SeasonEnum(String name, String desc) {
        this.name = name;
        this.desc = desc;
    }

    public String getName() {
        return name;
    }

    public String getDesc() {
        return desc;
    }

    @Override
    public String toString() {
        final StringBuffer sb = new StringBuffer("Season{");
        sb.append("name='").append(name).append('\'');
        sb.append(", desc='").append(desc).append('\'');
        sb.append('}');
        return sb.toString();
    }
}

